#include "ShareMemory.h"


CShareMemory::CShareMemory(void)
{
}


CShareMemory::~CShareMemory(void)
{
}

BOOL CShareMemory::Create( LPCTSTR lpszName, DWORD dwSize )
{
    ASSERT(lpszName != NULL);
    if (lpszName == NULL)
    {
        return FALSE;
    }

    BOOL bRet = FALSE;

    do 
    {
        m_hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, lpszName);
        if (NULL == m_hMapFile)
        {
            m_hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, dwSize, lpszName);
            if (NULL == m_hMapFile)
            {

            }
        }
    } while (FALSE);

    return bRet;
}

void CShareMemory::Close()
{
    if (NULL != m_hMapFile)
    {
        CloseHandle(m_hMapFile);
        m_hMapFile = NULL;
    }
}
